import request from '@/utils/request'
import request3 from '@/utils/request3'

/** 菜品统计 */
// 获取菜品统计列表
export function getDishesInfoData(dateType, topTypeId, perPage, page) {
  const data = {
    dateType,
    topTypeId,
    perPage,
    page
  }
  return request({
    url: 'api/v2/backend/dataStatistics',
    method: 'post',
    data
  })
}

/** 商户统计 */
// 获取经营数据看板
export function getBoardData() {
  return request({
    url: 'api/v1/backend/MarketBusinessTotal',
    method: 'post'
  })
}

// 获取商户统计列表
export function getBusinessList(
  ids, businessTypes, payWays, startTime, endTime, page, size
) {
  const formData = new FormData()
  formData.append('ids', ids)
  formData.append('businessTypes', businessTypes)
  formData.append('payWays', payWays)
  formData.append('startTime', startTime)
  formData.append('endTime', endTime)
  formData.append('page', page)
  formData.append('size', size)
  const data = formData
  return request3({
    url: 'aggs/business/dailySales/group',
    method: 'post',
    data
  })
}

// 获取交易列表
export function getTradingList(
  marketId,
  businessId,
  code,
  startDate,
  endDate,
  payWay,
  size,
  page
) {
  const formData = new FormData()
  formData.append('market_id', marketId)
  formData.append('business_id', businessId)
  formData.append('code', code)
  formData.append('start_date', startDate)
  formData.append('end_date', endDate)
  formData.append('pay_way', payWay)
  formData.append('size', size)
  formData.append('page', page)
  const data = formData
  return request3({
    url: 'search/transaction',
    method: 'post',
    data
  })
}

// 获取交易详情
export function getTradingDetail(transactionId) {
  const data = {
    transaction_id: transactionId
  }
  return request({
    url: 'api/v4/backend/TranscationDetails',
    method: 'post',
    data
  })
}
